package com.color.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.context.request.WebRequest;

@Controller
public class LoginCtrl {
	
	@RequestMapping(value="Login.htm",method = RequestMethod.POST)
	public String login(ModelMap model,WebRequest request){
		String userName = request.getParameter("userName");
		String passWord = request.getParameter("passWord");
		String strMsg = "";
		String forword = "login";
		
		if("admin".equals(userName)){
			
			if("admin".equals(passWord)){
				forword = "redirect:/Index.htm";
			}else{
				strMsg = "密码错误";
				
				model.addAttribute("strMsg",strMsg);
				model.addAttribute("userName",userName);
				
			}
			
		}else{
			strMsg = "账号不存在";
			
			model.addAttribute("strMsg",strMsg);
			model.addAttribute("userName",userName);
		}
		
		return forword;
	}
	
}
